const app = getApp();
Component({
  data: {
    selected: 0,
    color: "#7A7E83",
    selectedColor: "#3cc51f",
    list: [{
      pagePath: "/pages/index/index",
      iconPath: "/images/tabBar/index.png",
      selectedIconPath: "/images/tabBar/index_s.png",
      text: "首页",
      isSpecial: false
    }, {
      pagePath: "/pages/case/case",
        iconPath: "/images/tabBar/case.png",
        selectedIconPath: "/images/tabBar/case_s.png",
      text: "案例展示",
      isSpecial: false
    }, {
      pagePath: "/pages/brand/brand",
        iconPath: "/images/tabBar/brand.png",
        selectedIconPath: "/images/tabBar/brand_s.png",
      text: "品牌理念",
      isSpecial: false
    }
      , {
        pagePath: "/pages/about/about",
        iconPath: "/images/tabBar/about.png",
        selectedIconPath: "/images/tabBar/about_s.png",
        text: "关于我们",
        isSpecial: false
      }
      , {
        pagePath: "/pages/contact/contact",
        iconPath: "/images/tabBar/contact.png",
        selectedIconPath: "/images/tabBar/contact_s.png",
        text: '联系我们',
        isSpecial: false
      }],

    //适配IphoneX的屏幕底部横线
    isIphoneX: app.globalData.isIphoneX
  },
  attached() {},
  methods: {
    switchTab(e) {
      const dataset = e.currentTarget.dataset
      const path = dataset.path
      const index = dataset.index
      //如果是特殊跳转界面
      if (this.data.list[index].isSpecial) {
        wx.navigateTo({
          url: path
        })
      } else {
        //正常的tabbar切换界面
        wx.switchTab({
          url: path
        })
        this.setData({
          selected: index
        })
      }
    }
  }
})